package com.javaee.controller.user;



import com.javaee.BeforeBaseController;
import com.javaee.service.user.impl.Completion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Controller
@RequestMapping("/ai")
public class AiController extends BeforeBaseController {

    private final Completion completion;
    @Autowired
    public AiController(Completion completion) {
        this.completion = completion;
    }

    @RequestMapping("/chat")
    @ResponseBody
    public String chat(@RequestParam(value = "message", defaultValue = "Hi") String message) {
        String response = completion.chat(message);
        return response;
    }

    @RequestMapping("/toChat")
    public String toChat(Model model) {
        return "user/chat";
    }


}
